/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.oea.hibernate.entities;

import com.oea.hibernate.utilities.HibernateUtil;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 *
 * @author User
 */
@Table(name = "faculties_subjects")
@Entity
public class Faculty_Assign_Subject extends AbstractEntity {

    @Id
    @GeneratedValue

    @Column(name = "id")
    private Long id;

    @Column(name = "subid")
    private Long subid;

    @Column(name = "semester")
    private int semester;

    @Column(name = "bid")
    private Long branch;

    @Column(name = "fid")
    private Long fid;
    
      @Column(name = "nooflectures")
    protected int nooflectures;
     
      @Column(name = "nooflabs")
    protected int nooflabs;
   
    
    @Transient
    protected Subject subject;
    
    @Transient
    protected Faculty faculty;
    
    @Transient
    protected Branch branch_obj;

    public Subject getSubject() {
        return subject;
    }

    public void setSubject() {
        this.subject = (Subject) new Subject().getById(this.subid) ;
    }

    public Faculty getFaculty() {
        return faculty;
    }

    public void setFaculty() {
        this.faculty = (Faculty) new Faculty().getById(this.fid);
    }

    public Branch getBranch_obj() {
        return branch_obj;
    }

    public void setBranch_obj() {
        this.branch_obj =(Branch) new Branch().getById(this.branch) ;
    }
   
    
    
    

    public Long getFid() {
        return fid;
    }

    public void setFid(Long fid) {
        this.fid = fid;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getSubid() {
        return subid;
    }

    public void setSubid(Long subid) {
        this.subid = subid;
    }

    public int getSemester() {
        return semester;
    }

    public void setSemester(int semester) {
        this.semester = semester;
    }

    public Long getBranch() {
        return branch;
    }

    public void setBranch(Long branch) {
        this.branch = branch;
    }
    public int getNooflectures() {
        return nooflectures;
    }

    public void setNooflectures(int nooflectures) {
        this.nooflectures = nooflectures;
    }

    public int getNooflabs() {
        return nooflabs;
    }

    public void setNooflabs(int nooflabs) {
        this.nooflabs = nooflabs;
    }


  public static List<Faculty_Assign_Subject> getSubjectsOfFaculty(Long fid) {
        List<Faculty_Assign_Subject> list = null;
        Session ses = HibernateUtil.getSessionFactory().openSession();
        Query query = ses.createQuery("from Faculty_Assign_Subject where fid=" + fid);
        list = query.list();
        return list;
    }
}
